<template>
	<view class="my-content">
		<MyList :listData="list" :isCollect="true"></MyList>
		<uni-load-more :status="status" v-if="total>0"></uni-load-more>
	</view>
</template>

<script>
	const app=getApp();
	import MyList from '../components/my-list/my-list.vue'
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	import { myCollect } from '@/api/index.js'
	import { formatTime } from '@/util/time.js'
	export default{
		data(){
			return{
				openid:"",
				page:1,
				total:1,
				list:[],
				status:'more'
			}
		},
		methods:{
			myCollect:function(){
				this.status = 'loading'
				myCollect({
					page:this.page,
					openid:this.openid
				}).then(res=>{
					if (res.pagenum == res.total || res.total==0) {
						this.status = 'noMore'
					} else {
						this.status = 'more'
					}
					res.list.forEach(obj=>{
						obj.birth=formatTime(obj.birth)
					})
					this.list=this.list.concat(res.list);
					this.total=res.total
				})
			},
		},
		
		// 上拉加载
		onReachBottom() {
			if (this.page === this.total) {
				return false;
			}
			this.page += 1;
			this.myCollect();
		},
		
		onLoad() {
			this.openid=uni.getStorageSync('openid');
			this.myCollect();
			
		},
		components:{
			MyList,
			uniLoadMore
		}
	}
</script>

<style lang="scss" scoped>
	
</style>
